|
In programming, a gotcha is a valid construct in a system, program or programming language that works as documented but is counter-intuitive and almost invites mistakes because it is both easy to invoke and unexpected or unreasonable in its outcome.〔 The classic gotcha in C /C++ is the construct It is syntactically valid: it puts the value of b into a and then executes code if a is non-zero. Sometimes this is even intended. However most commonly it is a typo: the programmer probably meantwhich executes code if a and b are equal.〔(Gotcha definition at The Jargon File )〕 Modern compilers will generate a warning when encountering this construct. To avoid this gotcha, there is a recommendation〔("VOID EXP21-C. Place constants on the left of equality comparisons" )〕 to keep the constants in the left side of the comparison, e.g. 42 == x rather than x == 42 . This way, using = instead of == will cause a compiler error.==See also== * Usability 抄文引用元・出典: フリー百科事典『 ウィキペディア(Wikipedia)』 ■ウィキペディアで「Gotcha (programming)」の詳細全文を読む スポンサード リンク
|